package com.gin.supermarket_inventory_system.inventory.dto.param;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gin.database.dto.param.BasePageParam;
import com.gin.supermarket_inventory_system.inventory.enums.InventoryReceiptType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Comment;

/**
 * 库存单据详情
 * @since : 2023/10/12 16:47
 * @author : ginstone
 * @version : v1.0.0
 **/
@Getter
@Setter
@Schema(description = "分页查询参数: 库存单据详情")
public class InventoryReceiptDetailPageParam extends BasePageParam {
    @Schema(description = "库存ID")
    @NotNull
    long inventoryId;

    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    @Comment("单据类型")
    InventoryReceiptType type;


    @Override
    public void handleQueryWrapper(QueryWrapper<?> queryWrapper) {
        queryWrapper.eq("inventory_id", inventoryId);

        if (type != null) {
            queryWrapper.eq("type", type);
        }
    }
}
